<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
         //数组去重
         var array = [3, 4, 2, 3, 1, 4, ];
        function newArray(arr) {
            for (let i = 0; i < arr.length; i++) { 
                for (let j = i + 1; j < arr.length; j++) {
                    if (arr[i] === arr[j]) {
                        arr.splice(j, 1);
                        j--;
                    }
                }
            }
        }


        
       function  newArr(arr) {
           var newArr = [];
           for (var i = 0; i <arr.length ; i++) {
               if (newArr.indexOf(arr[i]) === -1){//在新数组中查找有没有这个元素
                   newArr.push(arr[i])//没有就添加到新数组中 有就不添加
               }
           }
           return newArr;
       }

       console.log(newArr(array))
   </script>
</body>
</html>